home *** CD-ROM | disk | FTP | other *** search
- program tststr1;
-
- {$APPTYPE CONSOLE}
-
- uses
- Windows,
- SysUtils;
-
- function CountAlpha1(S : string) : integer;
- var
- i : integer;
- begin
- Result := 0;
- for i := 1 to length(S) do
- if (S[i] in ['A'..'Z','a'..'z']) then
- inc(Result);
- end;
-
- function CountAlpha2(const S : string) : integer;
- var
- i : integer;
- begin
- Result := 0;
- for i := 1 to length(S) do
- if (S[i] in ['A'..'Z','a'..'z']) then
- inc(Result);
- end;
-
- var
- i : integer;
- StartTime : DWORD;
- begin
- writeln('testing routine 1...');
- StartTime := GetTickCount;
- for i := 1 to 10000000 do
- CountAlpha1('The cat sat on the mat');
- writeln('time taken: ', GetTickCount - StartTime);
-
- writeln('testing routine 2...');
- StartTime := GetTickCount;
- for i := 1 to 10000000 do
- CountAlpha2('The cat sat on the mat');
- writeln('time taken: ', GetTickCount - StartTime);
-
-
-
- readln;
- end.
-